package cn.com.guage.sort;

import java.util.Arrays;
import java.util.Random;

/**
 * 
 * 冒泡排序
 *
 */
public class SortTest {

	public static void main(String[] args) {

		int[] array = getArray();
		System.out.println(Arrays.toString(array));
		int[] sortArray = sortArray(array);
		System.out.println(Arrays.toString(sortArray));

	}

	public static int[] getArray() {
		int[] array = new int[10];
		for (int i = 0; i < 10; i++) {
			int radom = new Random().nextInt(1000);
			array[i] = radom;
		}
		return array;
	}

	public static int[] sortArray(int[] array) {
		for (int i = 0; i < array.length; i++) {
			int temp = array[i];
			for (int j = i+1; j < array.length; j++) {
				if (array[i] > array[j]) {
					array[i] = array[j];
					array[j] = temp;
				}
			}
		}
		return array;
	}
}
